package com.eva.databuilder.builders.cms;

import com.eva.cms.biz.resource.CmsResourceBiz;
import com.eva.cms.biz.resource.vo.CmsResourceVO;
import com.eva.databuilder.builders.AbstractTemplateDataBuilder;
import com.eva.databuilder.bo.TemplateDataParameters;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 构建多个资源列表数据
 */
@Component
public class MultipleResourceListBuilder extends AbstractTemplateDataBuilder<Map<String, List<CmsResourceVO>>> {

    private static final String PARAMETER_GROUP_IDS = "groupUids";

    @Resource
    private CmsResourceBiz cmsResourceBiz;

    @Override
    public Map<String, List<CmsResourceVO>> build(TemplateDataParameters parameters) {
        return cmsResourceBiz.findListByGroupUids(
                parameters.getList(PARAMETER_GROUP_IDS, Collections.emptyList()));
    }
}
